
/* GCSx
** FILEDIALOG.H
**
** Standard file open/save/save as dialogs
*/

/*****************************************************************************
** Copyright (C) 2003-2006 Janson
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** 
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
*****************************************************************************/

#ifndef __GCSx_FILEDIALOG_H_
#define __GCSx_FILEDIALOG_H_

// Returns false on cancel
// Filename can contain a suggested path/file
int fileOpen(int type, int requireWriteAccess, std::string& filename);

// Prompts to overwrite
// filename can be blank
// extension will be added if none given
// Returns false on cancel
// Previous filename may include a path or be blank
// May create a 0-byte file if one did not exist
int fileSaveAs(int type, std::string& filename);

// Cleans up some global objects
void destroyFileDialogGlobals();

// Treeview derivative that handles drive/directory trees
class DirectoryView : public TreeView {
private:
    std::string path;
    int hasSubDirs;
    
public:
    // Name is the displayed label, which should be the last portion of the path
    // Fullpath NULL for root
    DirectoryView(const std::string& name, const char* fullpath, void* tPtr = NULL, int (*tAction)(void* ptr, int code, int command, int check) = NULL, int topLevel = 0);
    ~DirectoryView();

    void redo(); // Closes and clears all items (refreshes)
    int hasSubItems() const;
    void expand(int state = 1);
    const char* getFullpath() const { return path.c_str(); };
};

#endif

